package cn.caskm.souvenirshopsystem.controller.api;

import cn.caskm.souvenirshopsystem.domain.Result;
import cn.caskm.souvenirshopsystem.domain.dto.PageDTO;
import cn.caskm.souvenirshopsystem.domain.po.Goods;
import cn.caskm.souvenirshopsystem.domain.query.CategoryGoodsQuery;
import cn.caskm.souvenirshopsystem.domain.query.PageQuery;
import cn.caskm.souvenirshopsystem.domain.vo.GoodsDetailVO;
import cn.caskm.souvenirshopsystem.service.GoodsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
@RequiredArgsConstructor
public class GoodsController {

    private final GoodsService goodsService;

    @GetMapping("/recommend")
    public Result<PageDTO<Goods>> getRecommendList(PageQuery query) {
        return goodsService.getRecommendList(query);
    }

    @GetMapping("/getByCategory")
    public Result<PageDTO<Goods>> getByCategory(CategoryGoodsQuery query) {
        return goodsService.getByCategory(query);
    }

    @GetMapping("/detail/{goodsId}")
    public Result<GoodsDetailVO> getGoodsDetail(@PathVariable("goodsId") Integer goodsId) {
        return goodsService.getGoodsDetail(goodsId);
    }
}
